library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  3.1.0     ✓ purrr   0.3.4
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(arsenal)
library(data.table)
## 
## Attaching package: 'data.table'
## The following object is masked from 'package:purrr':
## 
##     transpose
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
library(expss)
## 
## Attaching package: 'expss'
## The following objects are masked from 'package:data.table':
## 
##     copy, like
## The following objects are masked from 'package:stringr':
## 
##     fixed, regex
## The following objects are masked from 'package:purrr':
## 
##     keep, modify, modify_if, transpose, when
## The following objects are masked from 'package:tidyr':
## 
##     contains, nest
## The following objects are masked from 'package:dplyr':
## 
##     between, compute, contains, first, last, na_if, recode, vars
## The following object is masked from 'package:ggplot2':
## 
##     vars
sleephygiene <- read_csv("/Users/Ivanics/Desktop/SPH/4th term/HealthComm/Qualtrics post/Sleep Hygiene Post-Survey_May 4, 2021_09.05.csv")
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
sleephygiene$StartDate <- lubridate::ymd_hms(sleephygiene$StartDate)
## Warning: 2 failed to parse.
#Filter to include only responses beyond this time
sleephygiene <- sleephygiene %>% filter(StartDate >= "2021-04-29 00:00:00")

#Select out the variables we need
sleephygiene <- sleephygiene %>% select(Progress, `Duration (in seconds)`, Finished, LocationLatitude, LocationLongitude, DistributionChannel, UserLanguage, Q1, Q2, Q3, Q2_5_TEXT, Q4, Q5, Q6, Q37, Q92, Q93, Q94,  Q38, Q39, Q10_2, Q10_3, Q9, Q61, Q84, Q85, Q81, Q63, Q96_1, Q96_2, Q96_3, Q96_4, Q96_5, Q96_6, Q96_7, Q96_8, Q95, Q83, Q82, Q69, Q62, Q64, Q90, Q91, Q89_1, Q67_1, Q67_2, Q67_3, Q75_1, Q75_2, Q75_3, Q68, Q70, Q70_18_TEXT, Q87, Q71, Q72, Q79, Q79_5_TEXT, Q74, Q73, Q73_5_TEXT, Q59_1, Q59_2, Q59_3, Q59_4, Q44_1, Q44_2, Q44_3, Q44_4, Q44_5, Q44_6, Q44_7, Q44_8, Q44_9, Q52)

sleephygiene <- rowid_to_column(sleephygiene, "ID")
#General factor recoding
sleephygiene <- sleephygiene %>% mutate(
  Q1_consent = factor(Q1)) %>%
  mutate(Q2_program = factor(Q2)) %>%
  mutate(Q3_role = factor(Q3)) %>%
  mutate(Q4_gender = factor(Q4)) %>%
  mutate(Q5_age = factor(Q5)) %>%
  mutate(Q6_numberinhousehold = as.numeric(Q6)) %>%
  mutate(Q37_employed = factor(Q37)) %>%
  mutate(Q92_notSPHemployed = factor(Q92)) %>%
  mutate(Q93_worksetting = factor(Q93)) %>%
  mutate(Q94_dayornight = factor(Q94)) %>%
  mutate(Q38_worksetting = factor(Q38)) %>%
  mutate(Q39_dayornight = factor(Q39)) %>%
  mutate(Q10_hoursofsleeplast5workdays = as.numeric(Q10_2)) %>%
  mutate(Q10_hoursofsleeppastweekend = as.numeric(Q10_3)) %>%
  mutate(Q9_howoftensleepypastmonth = factor(Q9)) %>%
  mutate(Q61_howoftensleepypasttwoweeks = factor(Q61)) %>%
  mutate(Q84_awareofhowtoimprovesleepquality = factor(Q84)) %>%
  mutate(Q81_seenorheardfromGNbloombergcampaign = factor(Q81)) %>%
  mutate(Q63_recalltoolsfreetect = factor(Q63)) %>%
  mutate(Q96_picture1 = factor(Q96_1)) %>%
  mutate(Q96_picture2 = factor(Q96_2)) %>%
  mutate(Q96_picture3 = factor(Q96_3)) %>%
  mutate(Q96_picture4 = factor(Q96_4)) %>%
  mutate(Q96_picture5 = factor(Q96_5)) %>%
  mutate(Q96_picture6 = factor(Q96_6)) %>%
  mutate(Q96_picture7 = factor(Q96_7)) %>%
  mutate(Q96_picture8 = factor(Q96_8)) %>%
  mutate(Q95_talkedtoanyone = factor(Q95)) %>%
  mutate(Q82_knowanyonewhoengaged = factor(Q82)) %>%
  mutate(Q69_didyouengagewiththecampaign = factor(Q69)) %>%
  mutate(Q90_areyouhappywithyoursleepquality_awareofcampaign = factor(Q90)) %>%
  mutate(Q91_areyouhappywithyoursleepquality_notawareofcampaign = factor(Q91)) %>%
  mutate(Q89_ratesleepquality_notawareofcampaign = factor(Q89_1)) %>%
  mutate(Q67_move30minutes = as.numeric(Q67_1)) %>%
  mutate(Q67_breathing = as.numeric(Q67_2)) %>%
  mutate(Q67_powerdown = as.numeric(Q67_2)) %>%
  mutate(Q75_moving = factor(Q75_1)) %>%
  mutate(Q75_breathing = factor(Q75_2)) %>%
  mutate(Q75_powerdown = factor(Q75_3)) %>%
  mutate(Q68_timing = factor(Q68)) %>%
  mutate(Q87_idealtime = factor(Q87)) %>%
  mutate(Q74_rafflemotivating = factor(Q74)) %>%
  mutate(Q75_moving = factor(Q75_1)) %>%
  mutate(Q59_canmaintainhealthysleephabits = factor(Q59_1)) %>%
  mutate(Q59_cancutoutscreen = factor(Q59_2)) %>%
  mutate(Q59_canexercise = factor(Q59_3)) %>%
  mutate(Q59_canparticipateinbreathing = factor(Q59_4)) %>%
  mutate(Q44_goodnightsleepisimportant = factor(Q44_1)) %>%
  mutate(Q44_mentalclarity = factor(Q44_2)) %>%
  mutate(Q44_feelpositive = factor(Q44_3)) %>%
  mutate(Q44_cuttingoutscreenleadstobettersleep = factor(Q44_4)) %>%
  mutate(Q44_exercisingleadstobettersleep = factor(Q44_5)) %>%
  mutate(Q44_breathingexercisesleadstobettersleep = factor(Q44_6)) %>%
  mutate(Q44_iwillstopscreens = factor(Q44_7)) %>%
  mutate(Q44_iwillexercise = factor(Q44_8)) %>%
  mutate(Q44_iwillbreathe = factor(Q44_9)) %>%
  mutate(Q52_additionalcomments = factor(Q52))
#Q85
resp.split_85 <- strsplit(sleephygiene$Q85, ",")
lev <- unique(unlist(resp.split_85))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_85, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q85_waystoimprovesleepquality = case_when(
    Not.drinking.caffeinated.beverages.late.in.the.day == 1 ~ "Not drinking caffeinated beverages late in the day",
    Switching.off.electronics.one.hour.before.sleep == 1 ~ "Switching off electronics one hour before sleep",
    Incorporating.moderate.exercise.as.part.of.your.day == 1 ~ "Incorporating moderate exercise as part of your day",
    Increase.natural.bright.light.exposure.in.the.day == 1 ~ "Increase natural bright light exposure in the day",
    Reduce.irregular.or.long.daytime.naps == 1 ~ "Reduce irregular or long daytime naps",
    Try.to.sleep.and.wake.at.consistent.times == 1 ~ "Try to sleep and wake at consistent times",
    Take.a.melatonin.supplement == 1 ~ "Take a melatonin supplement",
    Decrease.alcohol.consumption == 1 ~ "Decrease alcohol consumption",
    Deep.breathing.exercises == 1 ~ "Deep breathing exercises"))

#Q83
resp.split_83 <- strsplit(sleephygiene$Q83, ",")
lev <- unique(unlist(resp.split_83))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_83, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q83_talkedtowho = case_when(
    Friends == 1 ~ "Friends",
    Spouse == 1 ~ "Spouse",
    Relatives == 1 ~ "Relatives",
    Colleague == 1 ~ "Colleague"))

#Q62
resp.split_62 <- strsplit(sleephygiene$Q62, ",")
lev <- unique(unlist(resp.split_62))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_62, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q62_howdidyouengage = case_when(
    Instagram.campaign == 1 ~ "Instagram campaign",
    Text.message.campaign == 1 ~ "Text message campaign",
    Word.of.mouth.discussion.with.others == 1 ~ "Word of mouth/discussion with others"))

#64
resp.split_64 <- strsplit(sleephygiene$Q64, ",")
lev <- unique(unlist(resp.split_64))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_64, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q64_whichtechniquedidyoutry = case_when(
    X.MoveMore == 1 ~ "Movemore",
    X.Breathe== 1 ~ "Breathe",
    X.PowerDown == 1 ~ "Powerdown",
    None.of.the.above == 1 ~ "None of the above"))

#70
resp.split_70 <- strsplit(sleephygiene$Q70, ",")
lev <- unique(unlist(resp.split_70))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_70, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q70_timingoftextsinconvenient = case_when(
    #Messages.were.too.frequent == 1 ~ "Messages were too frequent",
    Messages.were.too.infrequent== 1 ~ "Messages were too infrequent",
    Received.message.too.early.in.the.day == 1 ~ "Received message too early in the day",
    #Received.message.too.late.in.the.day == 1 ~ "Received message too late in the day",
    Other..please.explain.below. == 1 ~ "Other (please explain below)"))

#71
resp.split_71 <- strsplit(sleephygiene$Q71, ",")
lev <- unique(unlist(resp.split_71))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_71, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q71_whichchannelmosteducational = case_when(
    Text == 1 ~ "Text",
    Instagram == 1 ~ "Instagram"))
    #Discussion.with.others.about.the.campaign == 1 ~ "Discussion with others about the campaign",
    #None.of.the.above.1 == 1 ~ "None of the above"))

#72 - look into


#Q79
resp.split_79 <- strsplit(sleephygiene$Q79, ",")
lev <- unique(unlist(resp.split_79))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_79, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q79_moresuccessfuloutcomsuggestions = case_when(
    There.was.an.in.person.on.campus.component.to.the.campaign == 1 ~ "There was an in-person/on-campus component to the campaign",
    The.campaign.was.longer == 1 ~ "The campaign was longer",
    I.had.more.flexibility.in.my.day == 1 ~ "I had more flexibility in my day",
    There.were.subject.matter.experts.checking.in.with.me.one.on.one == 1 ~ "There were subject matter experts checking in with me one-on-one"))
    #Other == 1 ~ "Reduce irregular or long daytime naps",

#Q73
resp.split_73 <- strsplit(sleephygiene$Q73, ",")
lev <- unique(unlist(resp.split_73))
sleephygiene<- with(sleephygiene, data.frame(sleephygiene, t(sapply(resp.split_73, function(x) table(factor(x, levels=lev))))))

sleephygiene <- sleephygiene %>%
    mutate(Q73_hearabouthow = case_when(
    Instagram.1 == 1 ~ "Instagram",
    JHSPH.Activities.email == 1 ~ "JHSPH Activities email",
    #Class.announcement == 1 ~ "Class announcement",
    Word.of.mouth.discussion.with.others.1 == 1 ~ "Word of mouth/discussion with others"))
    #Other == 1 ~ "Reduce irregular or long daytime naps",

Plots for wakeup and sleep times

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
workdayssleep <- sleephygiene %>% ggplot( aes(x=Q10_hoursofsleeplast5workdays)) +
    geom_histogram( binwidth=1, fill="#69b3a2", color="#e9ecef", alpha=0.9) +
    ggtitle("Hours of sleep last five workdays") +
    theme(
      plot.title = element_text(size=32)
    ) +
  labs(x="Number of hours of sleep in the past five workdays", y="Number of participants")
ggplotly(workdayssleep)
## Warning: Removed 3 rows containing non-finite values (stat_bin).
#Plot for weekend
weekend <- sleephygiene %>% ggplot( aes(x=Q10_hoursofsleeppastweekend)) +
    geom_histogram( binwidth=1, fill="#69b3a2", color="#e9ecef", alpha=0.9) +
    ggtitle("Hours of sleep last weekend") +
    theme(
      plot.title = element_text(size=32)
    ) +
  labs(x="Number of hours of sleep in the past weekend", y="Number of participants")
ggplotly(weekend)
## Warning: Removed 3 rows containing non-finite values (stat_bin).
#Tab 1
sleephygiene$Q9_howoftensleepypastmonth <- factor(sleephygiene$Q9_howoftensleepypastmonth, levels = c("Never", "Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q61_howoftensleepypasttwoweeks <- factor(sleephygiene$Q61_howoftensleepypasttwoweeks, levels = c("Never", "Rarely", "Sometimes", "Very often", "Always"))
sleephygiene$Q89_ratesleepquality_notawareofcampaign <- factor(sleephygiene$Q89_ratesleepquality_notawareofcampaign, levels = c("Poor", "Fair", "Good", "Excellent"))
sleephygiene$Q75_moving <- factor(sleephygiene$Q75_moving, levels = c("Extremely unhelpful", "Somewhat unhelpful", "Neither helpful nor unhelpful", "Somewhat helpful", "Extremely helpful"))
sleephygiene$Q75_breathing <- factor(sleephygiene$Q75_breathing, levels = c("Extremely unhelpful", "Somewhat unhelpful", "Neither helpful nor unhelpful", "Somewhat helpful", "Extremely helpful"))
sleephygiene$Q75_powerdown <- factor(sleephygiene$Q75_powerdown, levels = c("Extremely unhelpful", "Somewhat unhelpful", "Neither helpful nor unhelpful", "Somewhat helpful", "Extremely helpful"))
sleephygiene$Q87_idealtime <- factor(sleephygiene$Q87_idealtime, levels = c("Early morning (6:00 am - 9:00 am)", "Late morning (9:01 am - 12:00 pm)", "Early afternoon (12:01 pm - 3:00 pm)", "Late afternoon (3:01 pm - 6:00 pm)", "Early evening (6:01 pm - 9:00 pm)", "Late evening (9:01 pm - 12:00 am)", "Other (please specify)"))
sleephygiene$Q59_canmaintainhealthysleephabits <- factor(sleephygiene$Q59_canmaintainhealthysleephabits, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q59_cancutoutscreen <- factor(sleephygiene$Q59_cancutoutscreen, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q59_canexercise <- factor(sleephygiene$Q59_canexercise, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q59_canparticipateinbreathing <- factor(sleephygiene$Q59_canparticipateinbreathing, levels = c("Not at all confident", "Somewhat confident", "Extremely confident"))
sleephygiene$Q44_goodnightsleepisimportant <- factor(sleephygiene$Q44_goodnightsleepisimportant, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_mentalclarity <- factor(sleephygiene$Q44_mentalclarity, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_feelpositive <- factor(sleephygiene$Q44_feelpositive, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_cuttingoutscreenleadstobettersleep <- factor(sleephygiene$Q44_cuttingoutscreenleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_exercisingleadstobettersleep <- factor(sleephygiene$Q44_exercisingleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_breathingexercisesleadstobettersleep <- factor(sleephygiene$Q44_breathingexercisesleadstobettersleep, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_iwillstopscreens <- factor(sleephygiene$Q44_iwillstopscreens, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_iwillexercise <- factor(sleephygiene$Q44_iwillexercise, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))
sleephygiene$Q44_iwillbreathe <- factor(sleephygiene$Q44_iwillbreathe, levels = c("Strongly disagree", "Somewhat disagree", "Neither agree nor disagree", "Somewhat agree", "Strongly agree"))

library(expss)
sleephygiene = apply_labels(sleephygiene,
                      Q3_role = "What is your role at Bloomberg",
                      Q4_gender = "Which best describes your gender identity?",
                      Q2_program = "What is your current program at Bloomberg?",
                      Q5_age = "How old are you?",
                      Q6_numberinhousehold = "How many people live in your household, including yourself?",
                      Q37_employed = "If you are a student at Bloomberg, are you currently employed outside of your education program?",
                      Q92_notSPHemployed = "Are you currently employed?",
                      Q93_worksetting = "Which of the following best describes your current work setting?",
                      Q94_dayornight = "Do you work day or night shifts?",
                      Q38_worksetting = "Which of the following best describes your current work setting?",
                      Q39_dayornight = "Do you work day or night shifts?",
                      Q10_hoursofsleeplast5workdays = "On average, how many hours of sleep did you get per night during the following periods of time: during the last 5 workdays?",
                      Q10_hoursofsleeppastweekend = "On average, how many hours of sleep did you get per night during the following periods of time: during the past weekend?",
                      Q9_howoftensleepypastmonth = "How often did you feel sleepy during the day in the past month?",
                      Q61_howoftensleepypasttwoweeks = "How often did you feel sleepy during the day during the past 2 weeks?",
                      Q84_awareofhowtoimprovesleepquality = "Do you know any ways a person can improve their sleep quality?",
                      Q85_waystoimprovesleepquality = "What are some of the ways to improve sleep quality that you know?",
                      Q81_seenorheardfromGNbloombergcampaign = "In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep?",
                      Q63_recalltoolsfreetect = "Can you recall any specific tools, techniques, or resources from the campaign? Please describe below.",
                      Q96_picture1 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 1",
                      Q96_picture2 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 2",
                      Q96_picture3 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 3",
                      Q96_picture4 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 4",
                      Q96_picture5 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 5",
                      Q96_picture6 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 6",
                      Q96_picture7 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 7",
                      Q96_picture8 = "Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 8",
                      Q95_talkedtoanyone = "Have you talked to anyone about the #GoodnightBloomberg campaign?",
                      Q83_talkedtowho = "Please indicate with whom you talked about #GoodnightBloomberg (check all that apply).",
                      Q82_knowanyonewhoengaged = "Do you know anyone who engaged in any way with the #GoodnightBloomberg campaign about promoting better sleep?",
                      Q69_didyouengagewiththecampaign = "Did you engage in any way with the #GoodnightBloomberg campaign led by JHSPH students during the past 2 weeks?",
                      Q62_howdidyouengage = "Please select which of the following parts of the #GoodnightBloomberg campaign you engaged in:",
                      Q64_whichtechniquedidyoutry = "Which of the following techniques did you try at least once in the last 2 weeks (choose all that apply)?", 
                      Q90_areyouhappywithyoursleepquality_awareofcampaign = "Are you happy with your sleep quality overall currently?", 
                      Q91_areyouhappywithyoursleepquality_notawareofcampaign = "Are you happy with your sleep quality overall currently?", 
                      Q89_ratesleepquality_notawareofcampaign = "Please rate your sleep quality from the following options: In the last two weeks? (on average)",
                      Q67_move30minutes =  "In the last two weeks, how many days did you participate in the following techniques? Move 30 minutes total per day",
                      Q67_breathing = "In the last two weeks, how many days did you participate in the following techniques? Use a breathing exercise",
                      Q67_powerdown = "In the last two weeks, how many days did you participate in the following techniques? Power down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed",
                      Q75_moving = "How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Moving 30 minutes total per day",
                      Q75_breathing = "How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Using a breathing exercise",
                      Q75_powerdown = "How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Powering down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed",
                      Q68_timing = "Was the timing of the texts/posts convenient for you to adopt the recommended activity? ",
                      Q70_timingoftextsinconvenient = "Please provide information below about why the timing of the texts/posts was inconvenient?", 
                      Q87_idealtime = "What would have been the ideal time to receive the message (EST/EDT)?",
                      Q71_whichchannelmosteducational = "Which channel did you find the most educational?",
                      Q79_moresuccessfuloutcomsuggestions = "I think I would have had a more successful outcome (e.g. better sleep quality) if (choose all that may apply):",
                      Q74_rafflemotivating = "Did you find the raffles motivating for participation in the #GoodnightBloomberg campaign?",
                      Q73_hearabouthow = "How did you hear about the #GoodnightBloomberg campaign?",
                      Q59_canmaintainhealthysleephabits = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can maintain healthy sleep habits.",
                      Q59_cancutoutscreen = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can cut out screen use 1 hour before bed.",
                      Q59_canexercise = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can exercise for 30 minutes total each day.", 
                      Q59_canparticipateinbreathing = "Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can participate in a breathing exercise during the day or before bed.", 
                      Q44_goodnightsleepisimportant = "Please rate your agreement with the following statements: Getting a good night's sleep is important to me.",
                      Q44_mentalclarity = "Please rate your agreement with the following statements: Having a regular sleep routine improves mental clarity/sharpness.",
                      Q44_feelpositive = "Please rate your agreement with the following statements: I feel positive about the quality of my sleep.",
                      Q44_cuttingoutscreenleadstobettersleep = "Please rate your agreement with the following statements: I think cutting out screen use 1 hour before bed leads to better sleep.",
                      Q44_exercisingleadstobettersleep = "Please rate your agreement with the following statements: I think exercising regularly leads to better sleep.",
                      Q44_breathingexercisesleadstobettersleep = "Please rate your agreement with the following statements: I think participating in breathing exercises during the day or before bed leads to better sleep.",
                      Q44_iwillstopscreens = "Please rate your agreement with the following statements: In the next two weeks, I will stop using screens 1 hour before bed for better sleep.",
                      Q44_iwillexercise = "Please rate your agreement with the following statements: In the next two weeks, I will exercise for at least 30 minutes total each day for better sleep.",
                      Q44_iwillbreathe = "Please rate your agreement with the following statements: In the next two weeks, I will do a daily breathing exercise for better sleep.",
                      Q52_additionalcomments = "Please share any additional comments or feedback you have about the #GoodnightBloomberg sleep campaign below."
                      )
attach(sleephygiene)
tab1 <- tableby(~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q10_hoursofsleeplast5workdays +
                  Q10_hoursofsleeppastweekend +
                  Q9_howoftensleepypastmonth +
                  Q61_howoftensleepypasttwoweeks +
                  Q84_awareofhowtoimprovesleepquality +
                  Q81_seenorheardfromGNbloombergcampaign +
                  #Q63_recalltoolsfreetect +
                  Q96_picture1 +
                  Q96_picture2 +
                  Q96_picture3 +
                  Q96_picture4 +
                  Q96_picture5 +
                  Q96_picture6 +
                  Q96_picture7 +
                  Q96_picture8 +
                  Q95_talkedtoanyone +
                  Q82_knowanyonewhoengaged +
                  Q69_didyouengagewiththecampaign +
                  Q67_move30minutes +
                  Q67_breathing +
                  Q67_powerdown +
                  Q68_timing + 
                  Q79_moresuccessfuloutcomsuggestions +
                  Q59_canmaintainhealthysleephabits +
                  Q59_cancutoutscreen +
                  Q59_canexercise +
                  Q59_canparticipateinbreathing +
                  Q44_goodnightsleepisimportant +
                  Q44_mentalclarity +
                  Q44_feelpositive +
                  Q44_cuttingoutscreenleadstobettersleep +
                  Q44_exercisingleadstobettersleep +
                  Q44_breathingexercisesleadstobettersleep +
                  Q44_iwillstopscreens +
                  Q44_iwillexercise +
                  Q44_iwillbreathe,
                data=sleephygiene, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=94)
What is your role at Bloomberg
   N-Miss 3
   Faculty/Staff Member 6 (6.6%)
   Full-time student 54 (59.3%)
   Part-time student 31 (34.1%)
Which best describes your gender identity?
   N-Miss 3
   Female 77 (84.6%)
   Male 13 (14.3%)
   Non-binary / third gender 1 (1.1%)
How old are you?
   N-Miss 3
   18-25 30 (33.0%)
   26-34 40 (44.0%)
   35-44 13 (14.3%)
   45-54 8 (8.8%)
How many people live in your household, including yourself?
   Median (Q1, Q3) 2.00 (2.00, 3.00)
If you are a student at Bloomberg, are you currently employed outside of your education program?
   N-Miss 3
   N/A - I am not a student at Bloomberg 6 (6.6%)
   No 43 (47.3%)
   Yes 42 (46.2%)
On average, how many hours of sleep did you get per night during the following periods of time: during the last 5 workdays?
   Median (Q1, Q3) 7.00 (6.00, 7.00)
On average, how many hours of sleep did you get per night during the following periods of time: during the past weekend?
   Median (Q1, Q3) 8.00 (7.00, 8.00)
How often did you feel sleepy during the day in the past month?
   N-Miss 38
   Never 2 (3.6%)
   Rarely 8 (14.3%)
   Sometimes 39 (69.6%)
   Very often 0 (0.0%)
   Always 7 (12.5%)
How often did you feel sleepy during the day during the past 2 weeks?
   N-Miss 34
   Never 2 (3.3%)
   Rarely 12 (20.0%)
   Sometimes 36 (60.0%)
   Very often 0 (0.0%)
   Always 10 (16.7%)
Do you know any ways a person can improve their sleep quality?
   N-Miss 1
   No 4 (4.3%)
   Yes 89 (95.7%)
In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep?
   N-Miss 1
   Don’t know 21 (22.6%)
   No 29 (31.2%)
   Yes 43 (46.2%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 1
   N-Miss 12
   No 16 (19.5%)
   Not sure 61 (74.4%)
   Yes 5 (6.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 2
   N-Miss 9
   No 4 (4.7%)
   Not sure 44 (51.8%)
   Yes 37 (43.5%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 3
   N-Miss 12
   No 14 (17.1%)
   Not sure 63 (76.8%)
   Yes 5 (6.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 4
   N-Miss 12
   No 13 (15.9%)
   Not sure 60 (73.2%)
   Yes 9 (11.0%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 5
   N-Miss 11
   No 7 (8.4%)
   Not sure 62 (74.7%)
   Yes 14 (16.9%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 6
   N-Miss 11
   No 11 (13.3%)
   Not sure 70 (84.3%)
   Yes 2 (2.4%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 7
   N-Miss 11
   No 9 (10.8%)
   Not sure 64 (77.1%)
   Yes 10 (12.0%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 8
   N-Miss 12
   No 9 (11.0%)
   Not sure 69 (84.1%)
   Yes 4 (4.9%)
Have you talked to anyone about the #GoodnightBloomberg campaign?
   N-Miss 1
   No 81 (87.1%)
   Yes 12 (12.9%)
Do you know anyone who engaged in any way with the #GoodnightBloomberg campaign about promoting better sleep?
   N-Miss 1
   No 84 (90.3%)
   Yes 9 (9.7%)
Did you engage in any way with the #GoodnightBloomberg campaign led by JHSPH students during the past 2 weeks?
   N-Miss 1
   No 73 (78.5%)
   Yes 20 (21.5%)
In the last two weeks, how many days did you participate in the following techniques? Move 30 minutes total per day
   Median (Q1, Q3) 9.00 (5.00, 12.00)
In the last two weeks, how many days did you participate in the following techniques? Use a breathing exercise
   Median (Q1, Q3) 3.00 (1.50, 6.00)
In the last two weeks, how many days did you participate in the following techniques? Power down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed
   Median (Q1, Q3) 3.00 (1.50, 6.00)
Was the timing of the texts/posts convenient for you to adopt the recommended activity?
   N-Miss 21
   No 31 (42.5%)
   Yes 42 (57.5%)
I think I would have had a more successful outcome (e.g. better sleep quality) if (choose all that may apply):
   N-Miss 24
   I had more flexibility in my day 29 (41.4%)
   The campaign was longer 18 (25.7%)
   There was an in-person/on-campus component to the campaign 16 (22.9%)
   There were subject matter experts checking in with me one-on-one 7 (10.0%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can maintain healthy sleep habits.
   N-Miss 3
   Not at all confident 16 (17.6%)
   Somewhat confident 58 (63.7%)
   Extremely confident 17 (18.7%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can cut out screen use 1 hour before bed.
   N-Miss 3
   Not at all confident 44 (48.4%)
   Somewhat confident 34 (37.4%)
   Extremely confident 13 (14.3%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can exercise for 30 minutes total each day.
   N-Miss 3
   Not at all confident 12 (13.2%)
   Somewhat confident 39 (42.9%)
   Extremely confident 40 (44.0%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can participate in a breathing exercise during the day or before bed.
   N-Miss 3
   Not at all confident 9 (9.9%)
   Somewhat confident 50 (54.9%)
   Extremely confident 32 (35.2%)
Please rate your agreement with the following statements: Getting a good night’s sleep is important to me.
   N-Miss 3
   Strongly disagree 0 (0.0%)
   Somewhat disagree 0 (0.0%)
   Neither agree nor disagree 1 (1.1%)
   Somewhat agree 18 (19.8%)
   Strongly agree 72 (79.1%)
Please rate your agreement with the following statements: Having a regular sleep routine improves mental clarity/sharpness.
   N-Miss 3
   Strongly disagree 0 (0.0%)
   Somewhat disagree 0 (0.0%)
   Neither agree nor disagree 0 (0.0%)
   Somewhat agree 15 (16.5%)
   Strongly agree 76 (83.5%)
Please rate your agreement with the following statements: I feel positive about the quality of my sleep.
   N-Miss 3
   Strongly disagree 7 (7.7%)
   Somewhat disagree 22 (24.2%)
   Neither agree nor disagree 16 (17.6%)
   Somewhat agree 35 (38.5%)
   Strongly agree 11 (12.1%)
Please rate your agreement with the following statements: I think cutting out screen use 1 hour before bed leads to better sleep.
   N-Miss 2
   Strongly disagree 1 (1.1%)
   Somewhat disagree 2 (2.2%)
   Neither agree nor disagree 14 (15.2%)
   Somewhat agree 28 (30.4%)
   Strongly agree 47 (51.1%)
Please rate your agreement with the following statements: I think exercising regularly leads to better sleep.
   N-Miss 2
   Strongly disagree 0 (0.0%)
   Somewhat disagree 1 (1.1%)
   Neither agree nor disagree 4 (4.3%)
   Somewhat agree 27 (29.3%)
   Strongly agree 60 (65.2%)
Please rate your agreement with the following statements: I think participating in breathing exercises during the day or before bed leads to better sleep.
   N-Miss 2
   Strongly disagree 0 (0.0%)
   Somewhat disagree 1 (1.1%)
   Neither agree nor disagree 21 (22.8%)
   Somewhat agree 38 (41.3%)
   Strongly agree 32 (34.8%)
Please rate your agreement with the following statements: In the next two weeks, I will stop using screens 1 hour before bed for better sleep.
   N-Miss 4
   Strongly disagree 18 (20.0%)
   Somewhat disagree 16 (17.8%)
   Neither agree nor disagree 18 (20.0%)
   Somewhat agree 24 (26.7%)
   Strongly agree 14 (15.6%)
Please rate your agreement with the following statements: In the next two weeks, I will exercise for at least 30 minutes total each day for better sleep.
   N-Miss 3
   Strongly disagree 2 (2.2%)
   Somewhat disagree 5 (5.5%)
   Neither agree nor disagree 14 (15.4%)
   Somewhat agree 27 (29.7%)
   Strongly agree 43 (47.3%)
Please rate your agreement with the following statements: In the next two weeks, I will do a daily breathing exercise for better sleep.
   N-Miss 3
   Strongly disagree 5 (5.5%)
   Somewhat disagree 15 (16.5%)
   Neither agree nor disagree 20 (22.0%)
   Somewhat agree 34 (37.4%)
   Strongly agree 17 (18.7%)
#If student
student <- sleephygiene %>% filter(Q3_role %in% c("Part-time student", "Full-time student"))

tab2 <- tableby(~ Q2_program,
                data=student, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab2, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=85)
What is your current program at Bloomberg?
   Doctoral Student 20 (23.5%)
   Masters Student 59 (69.4%)
   Other 3 (3.5%)
   Post-doctoral student 3 (3.5%)
#If employed 
nonbloombergstudentemployed <- sleephygiene %>% filter(Q37_employed == "N/A - I am not a student at Bloomberg")

tab3 <- tableby(~ Q92_notSPHemployed,
                data=nonbloombergstudentemployed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab3, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=6)
Are you currently employed?
   Yes 6 (100.0%)
#If employed and not bloomberg
employed <- nonbloombergstudentemployed %>% filter(Q92_notSPHemployed == "Yes")

tab4 <- tableby(~ Q93_worksetting,
                data=employed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab4, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=6)
Which of the following best describes your current work setting?
   I sometimes work at home and sometimes at another location 2 (33.3%)
   I work from home 4 (66.7%)
#wfh not bloomberg
#wfhnotbloomberg <- nonbloombergstudentemployed %>% filter(Q93_worksetting == "I work in a location away from my home")

#tab5 <- tableby(~ Q94_dayornight,
#                data=wfhnotbloomberg, test=TRUE, total=TRUE, 
#                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
#summary(tab5, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)

#student at bloomberg
studentemployed <- student %>% filter(Q37_employed == "Yes")

tab6 <- tableby(~ Q38_worksetting,
                data=studentemployed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab6, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=42)
Which of the following best describes your current work setting?
   N-Miss 1
   I sometimes work at home and sometimes at another location 10 (24.4%)
   I work from home 26 (63.4%)
   I work in a location away from my home 5 (12.2%)
studentemployedlocation <- student %>% filter(Q39_dayornight == "I work in a location away from my home")

#tab7 <- tableby(~ Q39_dayornight,
#                data=studentemployedlocation, test=TRUE, total=TRUE, 
#                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
#summary(tab7, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)


#Aware of how to improve sleep quality
awareofsleepqualityimprovements <- sleephygiene %>% filter(Q84_awareofhowtoimprovesleepquality == "Yes")

tab8 <- tableby(~ Q85_waystoimprovesleepquality,
                data=awareofsleepqualityimprovements, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab8, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=89)
What are some of the ways to improve sleep quality that you know?
   N-Miss 1
   Not drinking caffeinated beverages late in the day 81 (92.0%)
   Reduce irregular or long daytime naps 1 (1.1%)
   Switching off electronics one hour before sleep 5 (5.7%)
   Try to sleep and wake at consistent times 1 (1.1%)
#Talked to someone
talkedtosomeone <- sleephygiene %>% filter(Q95_talkedtoanyone == "Yes")

tab9 <- tableby(~ Q83_talkedtowho,
                data=talkedtosomeone, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab9, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=12)
Please indicate with whom you talked about #GoodnightBloomberg (check all that apply).
   N-Miss 1
   Colleague 1 (9.1%)
   Friends 8 (72.7%)
   Spouse 2 (18.2%)
#engaged in any way
engagedwiththecampaign <- sleephygiene %>% filter(Q69_didyouengagewiththecampaign == "Yes")

tab10 <- tableby(~ Q62_howdidyouengage +
                   Q64_whichtechniquedidyoutry +
                   Q90_areyouhappywithyoursleepquality_awareofcampaign +
                   Q75_moving +
                   Q75_breathing +
                   Q75_powerdown,
                data=engagedwiththecampaign, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab10, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=20)
Please select which of the following parts of the #GoodnightBloomberg campaign you engaged in:
   N-Miss 1
   Instagram campaign 13 (68.4%)
   Text message campaign 6 (31.6%)
Which of the following techniques did you try at least once in the last 2 weeks (choose all that apply)?
   Breathe 5 (25.0%)
   Movemore 13 (65.0%)
   None of the above 1 (5.0%)
   Powerdown 1 (5.0%)
Are you happy with your sleep quality overall currently?
   N-Miss 1
   No 8 (42.1%)
   Yes 11 (57.9%)
How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Moving 30 minutes total per day
   N-Miss 7
   Extremely unhelpful 0 (0.0%)
   Somewhat unhelpful 0 (0.0%)
   Neither helpful nor unhelpful 0 (0.0%)
   Somewhat helpful 9 (69.2%)
   Extremely helpful 4 (30.8%)
How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Using a breathing exercise
   N-Miss 10
   Extremely unhelpful 0 (0.0%)
   Somewhat unhelpful 0 (0.0%)
   Neither helpful nor unhelpful 5 (50.0%)
   Somewhat helpful 3 (30.0%)
   Extremely helpful 2 (20.0%)
How helpful did you find the following activities for getting better quality sleep in the past 2 weeks? Powering down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed
   N-Miss 13
   Extremely unhelpful 0 (0.0%)
   Somewhat unhelpful 0 (0.0%)
   Neither helpful nor unhelpful 2 (28.6%)
   Somewhat helpful 4 (57.1%)
   Extremely helpful 1 (14.3%)
#did not engagee in any way
noengagementwiththecampagin <- sleephygiene %>% filter(Q69_didyouengagewiththecampaign %in% c("No", "Don't know"))

tab11 <- tableby(~ Q91_areyouhappywithyoursleepquality_notawareofcampaign +
                   Q89_ratesleepquality_notawareofcampaign,
                data=noengagementwiththecampagin, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab11, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=73)
Are you happy with your sleep quality overall currently?
   N-Miss 25
   No 29 (60.4%)
   Yes 19 (39.6%)
Please rate your sleep quality from the following options: In the last two weeks? (on average)
   N-Miss 24
   Poor 4 (8.2%)
   Fair 20 (40.8%)
   Good 22 (44.9%)
   Excellent 3 (6.1%)
#not convenient 
notconvenient <- sleephygiene %>% filter(Q68_timing == "No")

tab12 <- tableby(~ Q70_timingoftextsinconvenient,
                data=noengagementwiththecampagin, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab12, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=73)
Please provide information below about why the timing of the texts/posts was inconvenient?
   N-Miss 55
   Messages were too infrequent 3 (16.7%)
   Other (please explain below) 14 (77.8%)
   Received message too early in the day 1 (5.6%)
#tooearlyintheday
tooearlyortoolate <- notconvenient %>% filter(Q70_timingoftextsinconvenient %in% c("Received message too early in the day", "Received message too late in the day"))

tab13 <- tableby(~ Q87_idealtime,
                data=tooearlyortoolate, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab13, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=2)
What would have been the ideal time to receive the message (EST/EDT)?
   Early morning (6:00 am - 9:00 am) 0 (0.0%)
   Late morning (9:01 am - 12:00 pm) 0 (0.0%)
   Early afternoon (12:01 pm - 3:00 pm) 0 (0.0%)
   Late afternoon (3:01 pm - 6:00 pm) 0 (0.0%)
   Early evening (6:01 pm - 9:00 pm) 2 (100.0%)
   Late evening (9:01 pm - 12:00 am) 0 (0.0%)
   Other (please specify) 0 (0.0%)
#whichmosteducational
instagramortext <- engagedwiththecampaign %>% filter(Q62_howdidyouengage %in% c("Instagram", "Text message campaign"))

#tab14 <- tableby(~ Q71_whichchannelmosteducational +
#                   Q72,
#                data=instagramortext, test=TRUE, total=TRUE, 
#                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
#summary(tab14, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)

#instagram
instagram <- engagedwiththecampaign %>% filter(Q62_howdidyouengage == "Instagram campaign")

tab15 <- tableby(~ Q74_rafflemotivating,
                data=instagram, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab15, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=13)
Did you find the raffles motivating for participation in the #GoodnightBloomberg campaign?
   No 3 (23.1%)
   Yes 10 (76.9%)
#seenorheardofthecampiagn
seenordheard <- sleephygiene %>% filter(Q81_seenorheardfromGNbloombergcampaign == "Yes")

tab16 <- tableby(~ Q81_seenorheardfromGNbloombergcampaign,
                data=seenordheard, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab16, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Overall (N=43)
In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep?
   Don’t know 0 (0.0%)
   No 0 (0.0%)
   Yes 43 (100.0%)
sleephygiene <- sleephygiene %>% mutate(Engagementyesno = case_when(
  Q69_didyouengagewiththecampaign == "Yes" ~ 1,
  Q69_didyouengagewiththecampaign == "No" ~ 0,
  Q69_didyouengagewiththecampaign == "Don't know" ~ 0,
  is.na(Q69_didyouengagewiththecampaign) ~ NA_real_)) %>%
  mutate(Engagementyesno = factor(Engagementyesno))

tab1 <- tableby(Engagementyesno ~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q10_hoursofsleeplast5workdays +
                  Q10_hoursofsleeppastweekend +
                  Q9_howoftensleepypastmonth +
                  Q61_howoftensleepypasttwoweeks +
                  Q84_awareofhowtoimprovesleepquality +
                  Q81_seenorheardfromGNbloombergcampaign +
                  Q96_picture1 +
                  Q96_picture2 +
                  Q96_picture3 +
                  Q96_picture4 +
                  Q96_picture5 +
                  Q96_picture6 +
                  Q96_picture7 +
                  Q96_picture8 +
                  Q95_talkedtoanyone +
                  Q82_knowanyonewhoengaged +
                  Q69_didyouengagewiththecampaign +
                  Q67_move30minutes +
                  Q67_breathing +
                  Q67_powerdown +
                  Q68_timing + 
                  Q79_moresuccessfuloutcomsuggestions +
                  Q59_canmaintainhealthysleephabits +
                  Q59_cancutoutscreen +
                  Q59_canexercise +
                  Q59_canparticipateinbreathing +
                  Q44_goodnightsleepisimportant +
                  Q44_mentalclarity +
                  Q44_feelpositive +
                  Q44_cuttingoutscreenleadstobettersleep +
                  Q44_exercisingleadstobettersleep +
                  Q44_breathingexercisesleadstobettersleep +
                  Q44_iwillstopscreens +
                  Q44_iwillexercise +
                  Q44_iwillbreathe,
                data=sleephygiene, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
0 (N=73) 1 (N=20) Total (N=93) p value
What is your role at Bloomberg 0.4301
   N-Miss 0 2 2
   Faculty/Staff Member 6 (8.2%) 0 (0.0%) 6 (6.6%)
   Full-time student 42 (57.5%) 12 (66.7%) 54 (59.3%)
   Part-time student 25 (34.2%) 6 (33.3%) 31 (34.1%)
Which best describes your gender identity? 0.7971
   N-Miss 0 2 2
   Female 61 (83.6%) 16 (88.9%) 77 (84.6%)
   Male 11 (15.1%) 2 (11.1%) 13 (14.3%)
   Non-binary / third gender 1 (1.4%) 0 (0.0%) 1 (1.1%)
How old are you? 0.9491
   N-Miss 0 2 2
   18-25 24 (32.9%) 6 (33.3%) 30 (33.0%)
   26-34 33 (45.2%) 7 (38.9%) 40 (44.0%)
   35-44 10 (13.7%) 3 (16.7%) 13 (14.3%)
   45-54 6 (8.2%) 2 (11.1%) 8 (8.8%)
How many people live in your household, including yourself? 0.0142
   Median (Q1, Q3) 2.00 (2.00, 3.00) 3.00 (2.00, 4.00) 2.00 (2.00, 3.00)
If you are a student at Bloomberg, are you currently employed outside of your education program? 0.0371
   N-Miss 0 2 2
   N/A - I am not a student at Bloomberg 6 (8.2%) 0 (0.0%) 6 (6.6%)
   No 38 (52.1%) 5 (27.8%) 43 (47.3%)
   Yes 29 (39.7%) 13 (72.2%) 42 (46.2%)
On average, how many hours of sleep did you get per night during the following periods of time: during the last 5 workdays? 0.4872
   Median (Q1, Q3) 7.00 (6.00, 7.00) 7.00 (6.00, 7.00) 7.00 (6.00, 7.00)
On average, how many hours of sleep did you get per night during the following periods of time: during the past weekend? 0.7732
   Median (Q1, Q3) 8.00 (7.00, 8.00) 8.00 (7.00, 8.75) 8.00 (7.00, 8.00)
How often did you feel sleepy during the day in the past month?
   N-Miss 29 8 37
   Never 2 (4.5%) 0 (0.0%) 2 (3.6%)
   Rarely 6 (13.6%) 2 (16.7%) 8 (14.3%)
   Sometimes 31 (70.5%) 8 (66.7%) 39 (69.6%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 5 (11.4%) 2 (16.7%) 7 (12.5%)
How often did you feel sleepy during the day during the past 2 weeks?
   N-Miss 26 7 33
   Never 2 (4.3%) 0 (0.0%) 2 (3.3%)
   Rarely 9 (19.1%) 3 (23.1%) 12 (20.0%)
   Sometimes 28 (59.6%) 8 (61.5%) 36 (60.0%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 8 (17.0%) 2 (15.4%) 10 (16.7%)
Do you know any ways a person can improve their sleep quality? 0.2851
   No 4 (5.5%) 0 (0.0%) 4 (4.3%)
   Yes 69 (94.5%) 20 (100.0%) 89 (95.7%)
In the last two-three weeks have you heard, seen, or received any information from the #GoodnightBloomberg campaign led by JHSPH students promoting better sleep? < 0.0011
   Don’t know 20 (27.4%) 1 (5.0%) 21 (22.6%)
   No 29 (39.7%) 0 (0.0%) 29 (31.2%)
   Yes 24 (32.9%) 19 (95.0%) 43 (46.2%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 1 0.0051
   N-Miss 8 3 11
   No 8 (12.3%) 8 (47.1%) 16 (19.5%)
   Not sure 53 (81.5%) 8 (47.1%) 61 (74.4%)
   Yes 4 (6.2%) 1 (5.9%) 5 (6.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 2 < 0.0011
   N-Miss 7 1 8
   No 4 (6.1%) 0 (0.0%) 4 (4.7%)
   Not sure 42 (63.6%) 2 (10.5%) 44 (51.8%)
   Yes 20 (30.3%) 17 (89.5%) 37 (43.5%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 3 < 0.0011
   N-Miss 8 3 11
   No 8 (12.3%) 6 (35.3%) 14 (17.1%)
   Not sure 56 (86.2%) 7 (41.2%) 63 (76.8%)
   Yes 1 (1.5%) 4 (23.5%) 5 (6.1%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 4 0.0181
   N-Miss 8 3 11
   No 7 (10.8%) 6 (35.3%) 13 (15.9%)
   Not sure 52 (80.0%) 8 (47.1%) 60 (73.2%)
   Yes 6 (9.2%) 3 (17.6%) 9 (11.0%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 5 < 0.0011
   N-Miss 8 2 10
   No 6 (9.2%) 1 (5.6%) 7 (8.4%)
   Not sure 56 (86.2%) 6 (33.3%) 62 (74.7%)
   Yes 3 (4.6%) 11 (61.1%) 14 (16.9%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 6 0.4631
   N-Miss 7 3 10
   No 8 (12.1%) 3 (17.6%) 11 (13.3%)
   Not sure 57 (86.4%) 13 (76.5%) 70 (84.3%)
   Yes 1 (1.5%) 1 (5.9%) 2 (2.4%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 7 < 0.0011
   N-Miss 8 2 10
   No 8 (12.3%) 1 (5.6%) 9 (10.8%)
   Not sure 55 (84.6%) 9 (50.0%) 64 (77.1%)
   Yes 2 (3.1%) 8 (44.4%) 10 (12.0%)
Were these materials were utilized in our #GoodnightBloomberg campaign? Picture 8 0.3251
   N-Miss 8 3 11
   No 7 (10.8%) 2 (11.8%) 9 (11.0%)
   Not sure 56 (86.2%) 13 (76.5%) 69 (84.1%)
   Yes 2 (3.1%) 2 (11.8%) 4 (4.9%)
Have you talked to anyone about the #GoodnightBloomberg campaign? < 0.0011
   No 71 (97.3%) 10 (50.0%) 81 (87.1%)
   Yes 2 (2.7%) 10 (50.0%) 12 (12.9%)
Do you know anyone who engaged in any way with the #GoodnightBloomberg campaign about promoting better sleep? < 0.0011
   No 70 (95.9%) 14 (70.0%) 84 (90.3%)
   Yes 3 (4.1%) 6 (30.0%) 9 (9.7%)
Did you engage in any way with the #GoodnightBloomberg campaign led by JHSPH students during the past 2 weeks? < 0.0011
   No 73 (100.0%) 0 (0.0%) 73 (78.5%)
   Yes 0 (0.0%) 20 (100.0%) 20 (21.5%)
In the last two weeks, how many days did you participate in the following techniques? Move 30 minutes total per day 0.3332
   Median (Q1, Q3) 9.00 (6.00, 12.00) 8.00 (4.25, 10.00) 9.00 (5.00, 12.00)
In the last two weeks, how many days did you participate in the following techniques? Use a breathing exercise 0.2702
   Median (Q1, Q3) 3.00 (1.00, 6.00) 5.00 (2.00, 7.00) 3.00 (1.50, 6.00)
In the last two weeks, how many days did you participate in the following techniques? Power down your screens (i.e. cell phone, tablet, computer, TV) 1 hour before bed 0.2702
   Median (Q1, Q3) 3.00 (1.00, 6.00) 5.00 (2.00, 7.00) 3.00 (1.50, 6.00)
Was the timing of the texts/posts convenient for you to adopt the recommended activity? 0.0181
   N-Miss 17 3 20
   No 28 (50.0%) 3 (17.6%) 31 (42.5%)
   Yes 28 (50.0%) 14 (82.4%) 42 (57.5%)
I think I would have had a more successful outcome (e.g. better sleep quality) if (choose all that may apply): 0.2661
   N-Miss 22 1 23
   I had more flexibility in my day 23 (45.1%) 6 (31.6%) 29 (41.4%)
   The campaign was longer 10 (19.6%) 8 (42.1%) 18 (25.7%)
   There was an in-person/on-campus component to the campaign 12 (23.5%) 4 (21.1%) 16 (22.9%)
   There were subject matter experts checking in with me one-on-one 6 (11.8%) 1 (5.3%) 7 (10.0%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can maintain healthy sleep habits. 0.3801
   N-Miss 0 2 2
   Not at all confident 12 (16.4%) 4 (22.2%) 16 (17.6%)
   Somewhat confident 49 (67.1%) 9 (50.0%) 58 (63.7%)
   Extremely confident 12 (16.4%) 5 (27.8%) 17 (18.7%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can cut out screen use 1 hour before bed. 0.4811
   N-Miss 0 2 2
   Not at all confident 33 (45.2%) 11 (61.1%) 44 (48.4%)
   Somewhat confident 29 (39.7%) 5 (27.8%) 34 (37.4%)
   Extremely confident 11 (15.1%) 2 (11.1%) 13 (14.3%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can exercise for 30 minutes total each day. 0.6481
   N-Miss 0 2 2
   Not at all confident 9 (12.3%) 3 (16.7%) 12 (13.2%)
   Somewhat confident 33 (45.2%) 6 (33.3%) 39 (42.9%)
   Extremely confident 31 (42.5%) 9 (50.0%) 40 (44.0%)
Please tell us how confident you feel practicing the following behaviors in order to get better sleep: I can participate in a breathing exercise during the day or before bed. 0.6471
   N-Miss 1 1 2
   Not at all confident 8 (11.1%) 1 (5.3%) 9 (9.9%)
   Somewhat confident 40 (55.6%) 10 (52.6%) 50 (54.9%)
   Extremely confident 24 (33.3%) 8 (42.1%) 32 (35.2%)
Please rate your agreement with the following statements: Getting a good night’s sleep is important to me.
   N-Miss 0 2 2
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Neither agree nor disagree 1 (1.4%) 0 (0.0%) 1 (1.1%)
   Somewhat agree 16 (21.9%) 2 (11.1%) 18 (19.8%)
   Strongly agree 56 (76.7%) 16 (88.9%) 72 (79.1%)
Please rate your agreement with the following statements: Having a regular sleep routine improves mental clarity/sharpness.
   N-Miss 1 1 2
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Neither agree nor disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat agree 11 (15.3%) 4 (21.1%) 15 (16.5%)
   Strongly agree 61 (84.7%) 15 (78.9%) 76 (83.5%)
Please rate your agreement with the following statements: I feel positive about the quality of my sleep. 0.9821
   N-Miss 0 2 2
   Strongly disagree 6 (8.2%) 1 (5.6%) 7 (7.7%)
   Somewhat disagree 18 (24.7%) 4 (22.2%) 22 (24.2%)
   Neither agree nor disagree 13 (17.8%) 3 (16.7%) 16 (17.6%)
   Somewhat agree 27 (37.0%) 8 (44.4%) 35 (38.5%)
   Strongly agree 9 (12.3%) 2 (11.1%) 11 (12.1%)
Please rate your agreement with the following statements: I think cutting out screen use 1 hour before bed leads to better sleep. 0.8331
   N-Miss 0 1 1
   Strongly disagree 1 (1.4%) 0 (0.0%) 1 (1.1%)
   Somewhat disagree 2 (2.7%) 0 (0.0%) 2 (2.2%)
   Neither agree nor disagree 12 (16.4%) 2 (10.5%) 14 (15.2%)
   Somewhat agree 21 (28.8%) 7 (36.8%) 28 (30.4%)
   Strongly agree 37 (50.7%) 10 (52.6%) 47 (51.1%)
Please rate your agreement with the following statements: I think exercising regularly leads to better sleep.
   N-Miss 0 1 1
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 1 (1.4%) 0 (0.0%) 1 (1.1%)
   Neither agree nor disagree 3 (4.1%) 1 (5.3%) 4 (4.3%)
   Somewhat agree 22 (30.1%) 5 (26.3%) 27 (29.3%)
   Strongly agree 47 (64.4%) 13 (68.4%) 60 (65.2%)
Please rate your agreement with the following statements: I think participating in breathing exercises during the day or before bed leads to better sleep.
   N-Miss 0 1 1
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 1 (1.4%) 0 (0.0%) 1 (1.1%)
   Neither agree nor disagree 15 (20.5%) 6 (31.6%) 21 (22.8%)
   Somewhat agree 31 (42.5%) 7 (36.8%) 38 (41.3%)
   Strongly agree 26 (35.6%) 6 (31.6%) 32 (34.8%)
Please rate your agreement with the following statements: In the next two weeks, I will stop using screens 1 hour before bed for better sleep. 0.8451
   N-Miss 1 2 3
   Strongly disagree 13 (18.1%) 5 (27.8%) 18 (20.0%)
   Somewhat disagree 14 (19.4%) 2 (11.1%) 16 (17.8%)
   Neither agree nor disagree 15 (20.8%) 3 (16.7%) 18 (20.0%)
   Somewhat agree 19 (26.4%) 5 (27.8%) 24 (26.7%)
   Strongly agree 11 (15.3%) 3 (16.7%) 14 (15.6%)
Please rate your agreement with the following statements: In the next two weeks, I will exercise for at least 30 minutes total each day for better sleep. 0.5051
   N-Miss 0 2 2
   Strongly disagree 2 (2.7%) 0 (0.0%) 2 (2.2%)
   Somewhat disagree 3 (4.1%) 2 (11.1%) 5 (5.5%)
   Neither agree nor disagree 13 (17.8%) 1 (5.6%) 14 (15.4%)
   Somewhat agree 21 (28.8%) 6 (33.3%) 27 (29.7%)
   Strongly agree 34 (46.6%) 9 (50.0%) 43 (47.3%)
Please rate your agreement with the following statements: In the next two weeks, I will do a daily breathing exercise for better sleep. 0.8291
   N-Miss 0 2 2
   Strongly disagree 4 (5.5%) 1 (5.6%) 5 (5.5%)
   Somewhat disagree 13 (17.8%) 2 (11.1%) 15 (16.5%)
   Neither agree nor disagree 16 (21.9%) 4 (22.2%) 20 (22.0%)
   Somewhat agree 28 (38.4%) 6 (33.3%) 34 (37.4%)
   Strongly agree 12 (16.4%) 5 (27.8%) 17 (18.7%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test
sleephygienepre <- readRDS(file="foranalysis.rds")

sleephygienepre <- sleephygienepre %>% 
  mutate(Q5_age = case_when(
    Q5_age >= 18 & Q5_age <= 25 ~ "18-25",
    Q5_age >= 26 & Q5_age <= 34 ~ "26-34",
    Q5_age >= 35 & Q5_age <= 44 ~ "35-44",
    Q5_age >= 45 & Q5_age <= 54 ~ "45-54",
    Q5_age >= 55 & Q5_age < 64 ~ "55-64",
    Q5_age >= 64 & Q5_age <= 75 ~ "64-75",
    Q5_age > 75 ~ "75+",
    is.na(Q5_age) ~ NA_character_
  )) %>% 
  mutate(Q5_age = factor(Q5_age)) %>%
  mutate(post = 0) %>% 
  mutate(
    Q10_hoursofsleeplast5workdays = Q10_workdayhoursofsleep,
    Q10_hoursofsleeppastweekend = Q11_weekendhoursofsleep,
    Q61_howoftensleepypasttwoweeks = Q9_howoftensleepy
  ) %>%
  select(post, Q3_role, Q2_program, Q4_gender, Q5_age, Q6_numberinhousehold, Q10_hoursofsleeplast5workdays, Q10_hoursofsleeppastweekend, Q61_howoftensleepypasttwoweeks)
  
sleephygienepost <- sleephygiene %>% mutate(post = 1) %>% select(post, Q3_role, Q2_program, Q4_gender, Q5_age, Q6_numberinhousehold, Q10_hoursofsleeplast5workdays, Q10_hoursofsleeppastweekend, Q61_howoftensleepypasttwoweeks) 

sleephygienepreandpost <- rbind(sleephygienepre, sleephygienepost)

sleephygienepreandpost <- sleephygienepreandpost %>% mutate(Q61_smaller = case_when(
  is.na(Q61_howoftensleepypasttwoweeks) ~ NA_character_,
  Q61_howoftensleepypasttwoweeks == "Never" ~ "Never",
  Q61_howoftensleepypasttwoweeks == "Rarely" ~ "Rarely",
  Q61_howoftensleepypasttwoweeks == "Sometimes" ~ "Sometimes",
  Q61_howoftensleepypasttwoweeks == "Very often" | Q61_howoftensleepypasttwoweeks == "Always" ~ "Very often or Alway",
)) %>%
  mutate(Q61_smaller = factor(Q61_smaller))

tab1 <- tableby(post ~ Q3_role +
                  Q2_program + 
                  Q4_gender + 
                  Q5_age + 
                  Q6_numberinhousehold +
                  Q10_hoursofsleeplast5workdays +
                  Q10_hoursofsleeppastweekend +
                  Q61_smaller,
                data=sleephygienepreandpost, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
0 (N=209) 1 (N=94) Total (N=303) p value
Q3_role 0.1891
   N-Miss 3 3 6
   Faculty/Staff Member 6 (2.9%) 6 (6.6%) 12 (4.0%)
   Full-time student 140 (68.0%) 54 (59.3%) 194 (65.3%)
   Part-time student 60 (29.1%) 31 (34.1%) 91 (30.6%)
Q2_program 0.0101
   N-Miss 9 9 18
   Doctoral Student 54 (27.0%) 20 (23.5%) 74 (26.0%)
   Masters Student 140 (70.0%) 59 (69.4%) 199 (69.8%)
   Other 1 (0.5%) 3 (3.5%) 4 (1.4%)
   Post doctoral student 5 (2.5%) 0 (0.0%) 5 (1.8%)
   Post-doctoral student 0 (0.0%) 3 (3.5%) 3 (1.1%)
Q4_gender 0.7721
   N-Miss 3 3 6
   Female 166 (80.6%) 77 (84.6%) 243 (81.8%)
   Male 35 (17.0%) 13 (14.3%) 48 (16.2%)
   Non-binary / third gender 4 (1.9%) 1 (1.1%) 5 (1.7%)
   Prefer not to say 1 (0.5%) 0 (0.0%) 1 (0.3%)
Q5_age 0.5751
   N-Miss 5 3 8
   18-25 64 (31.4%) 30 (33.0%) 94 (31.9%)
   26-34 98 (48.0%) 40 (44.0%) 138 (46.8%)
   35-44 32 (15.7%) 13 (14.3%) 45 (15.3%)
   45-54 9 (4.4%) 8 (8.8%) 17 (5.8%)
   55-64 1 (0.5%) 0 (0.0%) 1 (0.3%)
How many people live in your household, including yourself? 0.7132
   Median (Q1, Q3) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00)
During the past 5 workdays, how many hours of sleep did you get per night on average? 0.7522
   Median (Q1, Q3) 7.00 (6.00, 7.50) 7.00 (6.00, 7.00) 7.00 (6.00, 7.50)
During the past weekend, how many hours of sleep did you get per night on average? 0.3192
   Median (Q1, Q3) 8.00 (7.00, 9.00) 8.00 (7.00, 8.00) 8.00 (7.00, 9.00)
Q61_smaller 0.2541
   N-Miss 69 34 103
   Never 3 (2.1%) 2 (3.3%) 5 (2.5%)
   Rarely 27 (19.3%) 12 (20.0%) 39 (19.5%)
   Sometimes 99 (70.7%) 36 (60.0%) 135 (67.5%)
   Very often or Alway 11 (7.9%) 10 (16.7%) 21 (10.5%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test
library(sjPlot)
## Learn more about sjPlot with 'browseVignettes("sjPlot")'.
sleephygiene <- sleephygiene %>% mutate(Q69_didyouengagewiththecampaignbinary = case_when(
  Q69_didyouengagewiththecampaign == "No" ~ 0,
  Q69_didyouengagewiththecampaign == "Yes" ~ 1)) %>%
  mutate(Q4_gender_binary = case_when(
    Q4_gender == "Male" ~ 1,
    Q4_gender == "Female" ~ 0,
    TRUE ~ NA_real_
  )) %>%
  mutate(Q4_gender_binary = factor(Q4_gender_binary, labels = c("Female", "Male"))) %>%
  mutate(happywithsleepqualitycombined = case_when(
    Q90_areyouhappywithyoursleepquality_awareofcampaign == "Yes" ~ 1,
    Q90_areyouhappywithyoursleepquality_awareofcampaign == "No" ~ 0,
    Q91_areyouhappywithyoursleepquality_notawareofcampaign == "Yes" ~ 1,
    Q91_areyouhappywithyoursleepquality_notawareofcampaign == "No" ~ 0,
    Q89_ratesleepquality_notawareofcampaign == "Good" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Excellent" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Poor" ~ 0,
    Q89_ratesleepquality_notawareofcampaign == "Fair" ~ 0,
  )) %>%
  mutate(happywithsleepqualitycombined = factor(happywithsleepqualitycombined)) %>%
  mutate(Q67_1 = case_when(
    is.na(Q67_1) ~ 0,
    TRUE ~ as.numeric(Q67_1)
  )) %>%
  mutate(Q67_2 = case_when(
    is.na(Q67_2) ~ 0,
    TRUE ~ as.numeric(Q67_2)
  )) %>%
  mutate(Q67_3 = case_when(
    is.na(Q67_3) ~ 0,
    TRUE ~ as.numeric(Q67_3)
  )) %>%
  mutate(pointscombinedperdays = Q67_1 + Q67_2 + Q67_3) %>%
  mutate(ratesleepqualitycombined = case_when(
    Q89_ratesleepquality_notawareofcampaign == "Good" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Excellent" ~ 1,
    Q89_ratesleepquality_notawareofcampaign == "Poor" ~ 0,
    Q89_ratesleepquality_notawareofcampaign == "Fair" ~ 0,
  ))

#Participating in the campaign
mylogit <- glm(Q69_didyouengagewiththecampaignbinary ~ Q4_gender_binary + Q10_hoursofsleeplast5workdays + Q10_hoursofsleeppastweekend, family = binomial(link = "logit"), data = sleephygiene)
tab_model(mylogit)
  Q69_didyouengagewiththecampaignbinary
Predictors Odds Ratios CI p
(Intercept) 0.58 0.01 – 26.20 0.783
Q4_gender_binary: Male 0.77 0.11 – 3.36 0.752
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the last 5
workdays?
0.68 0.39 – 1.17 0.156
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the past
weekend?
1.26 0.80 – 2.04 0.326
Observations 90
R2 Tjur 0.026
#Happy with sleep quality
mylogit <- glm(happywithsleepqualitycombined ~ Q4_gender_binary + Q10_hoursofsleeplast5workdays + Q10_hoursofsleeppastweekend + Q69_didyouengagewiththecampaignbinary, family = binomial(link = "logit"), data = sleephygiene)
tab_model(mylogit)
  happywithsleepqualitycombined
Predictors Odds Ratios CI p
(Intercept) 0.00 0.00 – 0.01 <0.001
Q4_gender_binary: Male 1.86 0.48 – 7.56 0.372
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the last 5
workdays?
4.02 2.05 – 9.10 <0.001
On average, how many
hours of sleep did you
get per night during the
following periods of
time: during the past
weekend?
0.88 0.55 – 1.40 0.604
Q69_didyouengagewiththecampaignbinary 2.33 0.68 – 8.57 0.185
Observations 90
R2 Tjur 0.255
mylogit <- glm(happywithsleepqualitycombined ~ pointscombinedperdays, family = binomial(link = "logit"), data = sleephygiene)
tab_model(mylogit)
  happywithsleepqualitycombined
Predictors Odds Ratios CI p
(Intercept) 0.50 0.22 – 1.10 0.089
pointscombinedperdays 1.04 0.98 – 1.10 0.189
Observations 93
R2 Tjur 0.019